<?php
declare (strict_types = 1);

namespace app\admin\middleware;

class Check
{
    /**
     * 处理请求
     *
     * @param \think\Request $request
     * @param \Closure       $next
     * @return Response
     */
    public function handle($request, \Closure $next)
    {
    
        // halt($request);
        
        if (empty(session('adminSessionData')) && !preg_match('/login/',$request->request('s')) && !preg_match('/captcha/',$request->request('s'))){
            return redirect((string) url('/admin/login/index'));
        }
        return $next($request);
    }
    /**
     * 后置中间件
     */
    // public function handle($request, \Closure $next)
    // {
	// 	$response = $next($request);

    //     // 添加中间件执行代码
    //     echo "3333";
    //     return $response;
    // }
}
